package org.tuoren.official.es.convert;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import org.tuoren.official.es.domain.ProductEs;
import org.tuoren.official.es.domain.SearchResultEs;
import org.tuoren.official.es.domain.TNewsCenterES;

@Mapper
public interface SearchEsConvert {

    SearchEsConvert INSTANCE = Mappers.getMapper(SearchEsConvert.class);

    @Mapping(target = "id", source = "id")
    @Mapping(target = "title", source = "name")
    @Mapping(target = "summary", source = "summary")
    @Mapping(target = "content", source = "describes")
    @Mapping(target = "photoUrl", source = "photoUrl")
    @Mapping(target = "orderNum", source = "orderNum")
    @Mapping(target = "type", constant = "product")
    SearchResultEs toProduct(ProductEs productEs);

    @Mapping(target = "id", source = "id")
    @Mapping(target = "title", source = "title")
    @Mapping(target = "summary", source = "newDesc")
    @Mapping(target = "content", source = "content")
    @Mapping(target = "source", source = "source")
    @Mapping(target = "coverUrl", source = "coverUrl")
    @Mapping(target = "publishDate", source = "publishDate")
    @Mapping(target = "publishYear", source = "publishYear")
    @Mapping(target = "publishMonth", source = "publishMonth")
    @Mapping(target = "publishDateFormat", source = "publishDateFormat")
    @Mapping(target = "newType",  source = "newType")
    @Mapping(target = "type", constant = "news")
    SearchResultEs toNews(TNewsCenterES tNewsCenterES);
}
